package miracle.joker.design.command.demo2;

public class MoveCursorCommand implements Command {
    private Document document;
    private int steps;
	private int oldCursor;

    public MoveCursorCommand(Document document, int steps) {
    this.document = document;
    this.steps = steps;
}

    @Override
    public void execute() {
    oldCursor = document.getCursor();
    document.moveCursor(steps);
    }

    @Override
    public void undo() {
    document.moveCursor(oldCursor - document.getCursor());
}

    @Override
    public void redo() {
    document.moveCursor(steps);
}
}
